home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 10 / The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso / PC_SIGCD / 22 / 4 / DISK2247.ZIP / CBASE101.ZIP / LSEQ101.ZIP / LSNEXT.C < prev    next >
Text File  |  1990-06-20  |  2KB  |  84 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)lsnext.c    1.4 - 90/06/20" */
  5.  
  6. /* ansi headers */
  7. #include <errno.h>
  8.  
  9. /* local headers */
  10. #include "lseq_.h"
  11.  
  12. /*man---------------------------------------------------------------------------
  13. NAME
  14.      lsnext - next lseq record
  15.  
  16. SYNOPSIS
  17.      #include <lseq.h>
  18.  
  19.      int lsnext(lsp)
  20.      lseq_t *lsp;
  21.  
  22. DESCRIPTION
  23.      The lsnext function advances the cursor of lseq lsp to the next
  24.      record.  If the cursor is currently null, it will be advanced to
  25.      the first record.  If the cursor is currently on the last record,
  26.      it will be advanced to null.  If lsp is empty, the cursor will
  27.      remain set to null.
  28.  
  29.      lsnext will fail if one or more of the following is true:
  30.  
  31.      [EINVAL]       lsp is not a valid lseq pointer.
  32.      [LSELOCK]      lsp is not locked.
  33.      [LSENOPEN]     lsp is not open.
  34.  
  35. SEE ALSO
  36.      lscursor, lsfirst, lslast, lsprev.
  37.  
  38. DIAGNOSTICS
  39.      Upon successful completion, a value of 0 is returned.  Otherwise,
  40.      a value of -1 is returned, and errno set to indicate the error.
  41.  
  42. ------------------------------------------------------------------------------*/
  43. int lsnext(lsp)
  44. lseq_t *lsp;
  45. {
  46.     /* validate arguments */
  47.     if (!ls_valid(lsp)) {
  48.         errno = EINVAL;
  49.         return -1;
  50.     }
  51.  
  52.     /* check if not open */
  53.     if (!(lsp->flags & LSOPEN)) {
  54.         errno = LSENOPEN;
  55.         return -1;
  56.     }
  57.  
  58.     /* check if not locked */
  59.     if (!(lsp->flags & LSLOCKS)) {
  60.         errno = LSELOCK;
  61.         return -1;
  62.     }
  63.  
  64.     /* advance cursor */
  65.     if (lsp->clspos == NIL) {
  66.         lsp->clspos = lsp->lshdr.first;
  67.     } else {
  68.         lsp->clspos = lsp->clsrp->next;
  69.     }
  70.  
  71.     /* read in new current record */
  72.     if (lsp->clspos == NIL) {
  73.         ls_rcinit(lsp, lsp->clsrp);
  74.     } else {
  75.         if (ls_rcget(lsp, lsp->clspos, lsp->clsrp) == -1) {
  76.             LSEPRINT;
  77.             return -1;
  78.         }
  79.     }
  80.  
  81.     errno = 0;
  82.     return 0;
  83. }
  84.